package com.aliyeye.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @version V999
 * @package com.aliyeye.interceptor
 * @description: 来自三年开发经验，月薪100k，大佬代码
 * @author: 痞子洋
 * @date: 2019/6/9 21:23
 */
@Slf4j
public class MySpringBootInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        log.debug("前置拦截器日志.................");
        System.out.println("前置拦截器执行了");
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        log.debug("后置拦截器日志.................");
       System.out.println("后置拦截器执行了....");
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        log.debug("视图渲染日志.................");
        System.out.println("视图渲染拦截器执行了....");
    }
}
